<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends Controller {
	public function index(){
		$this->redirect("login");
	}
    public function login(){
    	if(IS_POST){
    		$user = M('User');
    		$password = I('password');
    		$where['account'] = I('account');
    		$auth = $user->where($where)->find();
    		if($auth){
    			if($auth['password']==md5($password)){
    				session('auth',$auth);
    				$this->success("登录成功",__APP__."/Admin/Account/index");
    			}else{
    				$this->error("账号或者密码错误");
    			}
    		}else{
    			$this->error("账号不存在");
    		}
    	}else{
	    	$this->display();
    	}
    }
    public function logout() {
    	session_unset();
    	session_destroy();
    	$this->redirect('Admin/Index/login');
    }
}